$(document).ready(function () {
    init()

    new Vue({
        el: '#app',
        data: {
            bankCardTypes: [],
            moneyTemp: '',
            term: '',
            bankCardType: '',
            bankCard: '',
            file: ''
        },
        methods: {
            getFile(event) {
                this.file = event.target.files[0]
            },
            insertLoan() {
                // var formData = new FormData()
                // console.log(formData)
                // console.log($("#loanForm").serialize()) // key=value&key=value
                // console.log(JSON.stringify($("#loanForm").serializeArray())) // json格式
                let formData = new FormData()
                formData.append("moneyTemp", this.moneyTemp)
                formData.append("term", this.term)
                formData.append("bankCardType", this.bankCardType)
                formData.append("bankCard", this.bankCard)
                formData.append("file", this.file)
                // console.log(formData)
                let config = {
                    headers: {
                        'Content-Type': 'multipart/form-data'
                    }
                }
                axios.post('insertLoan', formData, config).then(
                    response => {
                        if (response.data == 'ok') {
                            location.href = 'jump?url=success'
                        }
                    },
                    error => {
                        alert("出错啦", error.message);
                    }
                )
            }
        },
        created() {
            axios.get('queryBank').then(
                response => {
                    this.bankCardTypes = response.data
                    this.bankCardType = response.data[0].bankId
                },
                error => {
                    alert("出错啦");
                }
            )
        }
    })
})

function init() {
    $("#header").load("jump?url=common/header", null, function () {
        $(".nav_navs").children().eq(2).children().attr("class", "on")
        $(".header_h1").css("margin-top", "0px")
        $(".header_weixin").css("margin-top", "0px")
        $(".header_weixin>img").mouseover(function(){
            $(".header_weixinBig").css('display','block');
        })
        $(".header_weixin>img").mouseout(function(){
            $(".header_weixinBig").css('display','none');
        })
    })

    $("#footer").load("jump?url=common/footer")
}